color10 2.2.1
color10


Color 10 Click

Color 10 Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.


Click Library

  • Author : MikroE Team
  • Date : Feb 2020.
  • Type : I2C type

Software Support

Example Description

Color 10 Click is carrying a sensor for RGB and IR light sensing as well as the RGB diode incorporated on the board which makes it good color detection device when its combined with a white LED.

Example Libraries

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.Color10

Example Key Functions

Application Init

Initialize I2C driver

void application_init ( void )
{
log_cfg_t log_cfg;
uint8_t id_data;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, "---- Application Init ----" );
// Click initialization.
color10_init( &color10, &cfg );
Delay_ms ( 500 );
if ( color10_get_id( &color10 ) == COLOR10_DEVICE_ID )
{
log_printf( &logger, " -DEVICE ID OK\r\n" );
}
else
{
log_printf( &logger, " -DEVICE ID ERROR\r\n" );
for( ; ; );
}
log_printf( &logger, "-----Init done------\r\n" );
Delay_ms ( 500 );
}
#define COLOR10_CFG_AUTO_MODE
Definition color10.h:107
#define COLOR10_CFG_POWER_ON
Definition color10.h:111
#define COLOR10_DEVICE_ID
Definition color10.h:89
#define COLOR10_CFG_INTEGRATION_TIME_SETT_50_MS
Definition color10.h:103
#define COLOR10_CFG_TRIGGER_NO
Definition color10.h:109
#define COLOR10_CFG_GAIN_2_X1
Definition color10.h:118
#define COLOR10_CFG_GAIN_1_X1
Definition color10.h:114
#define COLOR10_CFG_HIGH_DYNAMIC_RANGE_1
Definition color10.h:102
#define COLOR10_MAP_MIKROBUS(cfg, mikrobus)
Definition color10.h:64
uint8_t color10_get_id(color10_t *ctx)
ID retrieval function.
void color10_config(color10_t *ctx, uint16_t cfg_data)
Configuration function.
void application_init(void)
Definition main.c:108
#define MIKROBUS_POSITION_COLOR10
Definition main.c:30

Application Task

This example senses orange, red, pink, purple, blue, cyan, green or yellow color and IR light and print it via UART terminal.

void application_task ( void )
{
uint16_t read_data;
float color_data;
read_data = color10_generic_read ( &color10, COLOR10_CMD_REG_IR );
log_printf( &logger, " -IR value: %d\r\n", read_data );
log_printf( &logger, " -Color: " );
log_printf( &logger, " ********************** \r\n" );
Delay_ms ( 1000 );
}
#define COLOR10_CMD_REG_IR
Definition color10.h:86
void write_color(void)
Definition main.c:40
void application_task(void)
Definition main.c:155

Application Output

This Click board can be interfaced and monitored in two ways:

  • Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
  • UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.

Additional Notes and Information

The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.